From: William Manley Date: Mon, 18 Jul 2016 16:03:11 +0000 (+0100) Subject: ostree-prepare-root as init: exec init from deployment if run as PID1 X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~49^2~34 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=c9551dc2310c86afebb33b3e58d5a04a3ea18a1d;p=ostree.git ostree-prepare-root as init: exec init from deployment if run as PID1 This supports running ostree on embedded platforms without an initrd. Specificially I'm trying to do bringup on an NVidia Tegra based Jetson TK1 dev board. Closes: #403 Approved by: cgwalters --- diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index df3e3219..a233007e 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -156,12 +156,10 @@ main(int argc, char *argv[]) int orig_cwd_dfd; if (argc < 2) - { - fprintf (stderr, "usage: ostree-prepare-root SYSROOT\n"); - exit (EXIT_FAILURE); - } + root_mountpoint = "/"; + else + root_mountpoint = argv[1]; - root_mountpoint = argv[1]; deploy_path = resolve_deploy_path (root_mountpoint); /* Create a temporary target for our mounts in the initramfs; this will @@ -303,6 +301,15 @@ main(int argc, char *argv[]) perrorv ("failed to MS_MOVE %s to %s", deploy_path, root_mountpoint); exit (EXIT_FAILURE); } - - exit (EXIT_SUCCESS); + + if (getpid() == 1) + { + execl ("/sbin/init", "/sbin/init", NULL); + perrorv ("failed to exec init inside ostree"); + exit (EXIT_FAILURE); + } + else + { + exit (EXIT_SUCCESS); + } }